'''
Created on 14.12.2012

@author: fre
'''
from game import GameLogic
from game.player.alpha_beta_player.alpha_beta_framework.heuristic.CompleteFieldHeuristic import CompleteFieldHeuristic

class CompleteFieldGroupHeuristic(CompleteFieldHeuristic):
    '''
    classdocs
    '''
    def inLoopHeuristic(self, field, action, color, nextColor, depth, position):
        x,y = position
        if field.get(x,y) == color:
            self.neighbours += len(GameLogic.getNeighboursOfSameColor(field, position, self.visited))+1
        
    def afterLoopHeuristic(self):
        return self.neighbours
        
    def prepare(self):
        self.visited = set()
        self.neighbours = 0
        
        